package com.coocaa.x.app.hall.topic;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;

import com.coocaa.x.app.hall.parser.ParserData;
import com.coocaa.x.app.hall.parser.ViewParser;
import com.coocaa.x.uipackage.BaseView;

/**
 * 为画廊定义适配器 * @author Administrator *
 */
public class HSVAdapter extends BaseAdapter {
    private List<String> list;
    private Context context;

    public HSVAdapter(Context context, List<String> jsonList) {
        this.context = context;
        this.list = jsonList;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public ParserData.Root_Node getItem(int location) {

        ParserData.Root_Node action = ParserData.Layout_Node.parseJObject(list.get(location), ParserData.Root_Node.class);
        return action;
    }

    @Override
    public long getItemId(int arg0) {
        return arg0;
    }

    @Override
    public View getView(int location, View arg1, ViewGroup arg2) {
        ParserData.Root_Node action = getItem(location); // 获取当前的Item
        String viewJason = action.view;
        BaseView view = parse(viewJason);

        ParserData.AppInfo_Node infoAction = ParserData.AppInfo_Node.parseJObject(list.get(location), ParserData.AppInfo_Node.class);
        if(infoAction != null) {
            ParserData.AppInfo_Node.App_Info info = ParserData.AppInfo_Node.parseJObject(infoAction.appInfo, ParserData.AppInfo_Node.App_Info.class);
        }
        return view;
    }

    public BaseView parse(String json) {
        BaseView view = null;
        ViewParser parser = new ViewParser(context);
        view = parser.parse(json);

        return view;
    }

}
